home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue67 / express / PlotFormUnit.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-01-31  |  1.3 KB  |  66 lines

  1. unit PlotFormUnit;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Parser10, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
  8.  
  9. type
  10.   TPlotForm = class(TForm)
  11.     MathExprParser: TParser;
  12.     Chart: TChart;
  13.     Panel1: TPanel;
  14.     ExpressionEdit: TEdit;
  15.     Label1: TLabel;
  16.     XFromEdit: TEdit;
  17.     XToEdit: TEdit;
  18.     XStepEdit: TEdit;
  19.     Label2: TLabel;
  20.     Label3: TLabel;
  21.     Label4: TLabel;
  22.     GoBtn: TButton;
  23.     LineSeries: TFastLineSeries;
  24.     procedure GoBtnClick(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   PlotForm: TPlotForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TPlotForm.FormCreate(Sender: TObject);
  40. begin
  41.   XStepEdit.Text := FloatToStr(0.1);
  42. end;
  43.  
  44. procedure TPlotForm.GoBtnClick(Sender: TObject);
  45. var
  46.   X: Double;
  47.   XTo: Double;
  48.   XStep: Double;
  49.   Y: Double;
  50. begin
  51.   MathExprParser.Expression := ExpressionEdit.Text;
  52.   LineSeries.Clear;
  53.   X     := StrToFloat(XFromEdit.Text);
  54.   XTo   := StrToFloat(XToEdit.Text);
  55.   XStep := StrToFloat(XStepEdit.Text);
  56.   while X <= XTo do
  57.   begin
  58.     MathExprParser.X := X;
  59.     Y := MathExprParser.Value;
  60.     LineSeries.AddXY(X, Y, '');
  61.     X := X + XStep;
  62.   end;
  63. end;
  64.  
  65. end.
  66.